package com.apes.fico.finance.respository;

import com.apes.fico.finance.model.statements.BalanceSheet;
import com.apes.framework.jpa.repository.CustomRepository;
import org.springframework.data.jpa.repository.Query;

import java.util.List;
import java.util.Map;

public interface BalanceSheetRepository extends CustomRepository<BalanceSheet, String> {

    @Query(value = "SELECT a.*," +
            "       (SELECT to_char(REPLACE(wm_concat(operator || '#'|| acc_code || '$'), ',', ''))" +
            "           FROM gl_balance_sheet_formula b" +
            "          WHERE a.ass_seq = b.seq" +
            "          GROUP BY seq) asschart," +
            "       (SELECT to_char(REPLACE(wm_concat(operator || '#'|| acc_code || '$'), ',', ''))" +
            "           FROM gl_balance_sheet_formula b" +
            "          WHERE a.liability_equity_seq = b.seq" +
            "          GROUP BY seq) liabilityequitychart" +
            "  FROM gl_balance_sheet a",nativeQuery = true)
    List<Map> findBalance();
}
